package io.gitee.yanbinchen.autoconfigure;

import io.gitee.yanbinchen.DelSuperCacheAspect;
import io.gitee.yanbinchen.SuperCacheAspect;
import io.gitee.yanbinchen.SuperCacheService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author: alex
 * @since : 2025-02-28 17:44
 */
@AutoConfiguration
@Import({SuperCacheService.class, SuperCacheAspect.class, DelSuperCacheAspect.class})
public class SuperCacheAutoConfiguration {

    @Bean
    public RedisTemplate<String, byte[]> superCacheTemplate(RedisConnectionFactory factory) {
        RedisTemplate<String, byte[]> template = new RedisTemplate<>();
        template.setConnectionFactory(factory);
        template.setKeySerializer(new StringRedisSerializer());
        template.setValueSerializer(null);
        return template;
    }
}
